package com.skivingcloud.report.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.skivingcloud.report.entity.ReportLuckysheetCell;
import com.skivingcloud.report.mapper.ReportLuckysheetCellMapper;
import com.skivingcloud.report.service.ReportLuckysheetCellService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.skivingcloud.common.utils.PageParameter;

/**
 * 协同文档单元格数据表 服务层实现。
 *
 * @author skivingcloud
 * @since 2024-11-07
 */
@Service
public class ReportLuckysheetCellServiceImpl extends ServiceImpl<ReportLuckysheetCellMapper, ReportLuckysheetCell> implements ReportLuckysheetCellService {

    /**
     * 分页查询协同文档单元格数据表
     *
     * @param parameter 查询参数
     * @return 分页查询结果
     */
    @Override
    public Page<ReportLuckysheetCell> queryByPage(PageParameter<ReportLuckysheetCell> parameter){
        Page<ReportLuckysheetCell> page = new Page<>(parameter.getPage(), parameter.getPageSize());
        QueryWrapper queryWrapper = QueryWrapper.create();
        if (parameter.getParam() != null) {
            //查询条件
            if (StringUtils.isNoneBlank(parameter.getParam().getId())) {
                queryWrapper.and(ReportLuckysheetCell::getId).like(parameter.getParam().getId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getBlockId())) {
                queryWrapper.and(ReportLuckysheetCell::getBlockId).like(parameter.getParam().getBlockId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getSheetIndex())) {
                queryWrapper.and(ReportLuckysheetCell::getSheetIndex).like(parameter.getParam().getSheetIndex());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getListId())) {
                queryWrapper.and(ReportLuckysheetCell::getListId).like(parameter.getParam().getListId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCellData())) {
                queryWrapper.and(ReportLuckysheetCell::getCellData).like(parameter.getParam().getCellData());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDelFlag())) {
                queryWrapper.and(ReportLuckysheetCell::getDelFlag).like(parameter.getParam().getDelFlag());
            }
        }
        return this.page(page, queryWrapper);
    }
}
